package com.spark.incoicings.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spark.incoicings.dao.SalesReceiptMapper;
import com.spark.incoicings.service.SalesReceiptService;
import com.spark.incoicings.vo.SalesReceiptVO;
import com.spark.invoicings.entity.SalesReceipt;
import com.spark.invoicings.utils.Result;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SalesReceiptServiceImpl extends ServiceImpl<SalesReceiptMapper, SalesReceipt> implements SalesReceiptService {

    @Resource
    private SalesReceiptMapper salesReceiptMapper;
    @Override
    public Result selectReceiptCount() {
        List<SalesReceiptVO> salesReceipts = salesReceiptMapper.selectReceiptCount();
        salesReceipts.forEach(s->{
            String original = s.getMonth();
            String year = original.substring(0,4);
            String month = original.substring(4);
            String modified = year+"年"+month+"月";
            s.setMonth(modified);
        });
        return Result.success(200,"success",salesReceipts);
    }
}
